pub struct CommonResponseHelper {
    pub code: i32,
    pub error_msg: Option<String>,
}

use proto_lib::CommonResponse;
use crate::ErrorCode;
use crate::types::*;
impl CommonResponseHelper {
    pub fn new(error:ErrorCode) -> Self {
        Self {
            code:error.code(),
            error_msg: Option::from(error.message().to_string()),
        }
    }

    pub fn ok()->Self {
        Self {
            code : 0,
            error_msg: None,
        }
    }
}

impl From<CommonResponseHelper> for CommonResponse {
    fn from(proto: CommonResponseHelper) -> Self {
        Self {
            code:proto.code,
            error_msg: proto.error_msg,
        }
    }
}
